<div class="box box-primary">
    <?php echo form_open_multipart('', 'role="form"'); ?>
    <div class="box-body">
        <div class="">
            <button type="submit" name="s_e" class="btn btn-sm btn-success"><i class="fa fa-save"></i> 保存
            </button>
            <button type="submit" name="s_c" class="btn btn-sm btn-info"><i class="fa fa-crop"></i> 保存后关闭
            </button>
            <button type="submit" name="s_n" class="btn btn-sm btn-primary"><i class="fa fa-anchor"></i> 新增保存
            </button>
        </div>
        <br/>

        <div class="clearfix"></div>
        <div class="row">
            <div class="col-sm-8">
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="wallpaper_name">壁纸名称 *</label>
                            <input type="text" class="form-control" id="wallpaper_name" name="wallpaper_name"
                                   placeholder="壁纸名称" required
                                   value="<?php echo set_value('wallpaper_name', ($wallpaper ? $wallpaper->wallpaper_name : '')); ?>">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="wallpaper_slug">短网址</label>
                            <input type="text" class="form-control" id="wallpaper_slug" name="wallpaper_slug"
                                   placeholder="为了不影响SEO，请用英文"
                                   value="<?php echo set_value('wallpaper_slug', ($wallpaper ? $wallpaper->wallpaper_slug : '')); ?>">
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="user_seq_id">用户ID*</label>
                            <input type="number" class="form-control" id="user_seq_id" name="user_seq_id"
                                   placeholder="User ID" required
                                   value="<?php echo set_value('user_seq_id', ($wallpaper ? $wallpaper->user_seq_id : $this->user->get_id())); ?>">
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="category_seq_id">分类 *</label>
                            <?php echo form_dropdown('category_seq_id', array('' => '选择分类') + ($categories ? $categories : array()), ($wallpaper ? $wallpaper->category_seq_id : array()), 'class="form-control input-sm select2" required id=""'); ?>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="wallpaper_status">审核状态 *</label>
                            <div>
                                <label style="padding-left: 0" class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_status', '1', ($wallpaper ? ($wallpaper->wallpaper_status ? TRUE : FALSE) : TRUE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_status"
                                        value="1">
                                    已审核
                                </label>
                                <label class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_status', '0', ($wallpaper ? (!$wallpaper->wallpaper_status ? TRUE : FALSE) : FALSE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_status"
                                        value="0">
                                    待审核
                                </label>
                            </div>
                        </div>
                        <div class="form-group">
                            <label for="wallpaper_status">验收状态 </label>
                            <div>
                                <label style="padding-left: 0" class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_approved', '1', ($wallpaper ? ($wallpaper->wallpaper_approved ? TRUE : FALSE) : TRUE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_approved"
                                        value="1">
                                    已验收
                                </label>
                                <label class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_approved', '0', ($wallpaper ? (!$wallpaper->wallpaper_approved ? TRUE : FALSE) : FALSE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_approved"
                                        value="0">
                                    待验收
                                </label>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-6">
                        <div class="form-group">
                            <label for="wallpaper_featured">壁纸推荐</label>

                            <div>
                                <label style="padding-left: 0" class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_featured', '1', ($wallpaper ? ($wallpaper->wallpaper_featured ? TRUE : FALSE) : FALSE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_featured"
                                        value="1">
                                    推荐
                                </label>
                                <label class="radio-inline">
                                    <input <?php echo set_radio('wallpaper_featured', '0', ($wallpaper ? (!$wallpaper->wallpaper_featured ? TRUE : FALSE) : TRUE)); ?>
                                        class="icheck" type="radio"
                                        name="wallpaper_featured"
                                        value="0">
                                    取消
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="col-sm-4">
                <label for="wallpaper_image_path">壁纸图片</label>
                <?php if ($image) { ?>
                    <input type="hidden" name="temp_image_path" value="<?php echo $image; ?>"/>
                <?php } ?>
                <?php $image_c = $this->image_workshop->crop_image($image, 250, 140, 'MM', 'temp'); ?>
                <div style="display: inline-block;margin-bottom: 20px" class="img_postions">
                    <img style="margin-bottom: 0" class="thumbnail" src="<?php echo $image_c; ?>" alt=""/>
                    <?php $positions = $this->image_workshop->positions; ?>
                    <?php foreach ($positions as $po) { ?>
                        <div class="ap <?php echo $po; ?>">
                            <input
                                type="radio" <?php echo set_radio('wallpaper_crop_position', $po, ($wallpaper && $wallpaper->wallpaper_crop_position == $po ? TRUE : ($po == 'MM' ? TRUE : FALSE))); ?>
                                name="wallpaper_crop_position"
                                value="<?php echo $po; ?>">
                        </div>
                    <?php } ?>
                </div>


                <input <?php echo(!$image ? 'required' : ''); ?> name="wallpaper_image_path" class="form-control"
                                                                 type="file" id="wallpaper_image_path">

                <p class="help-block">
                    <?php if ($this->config->item('minimum_width')) echo '壁纸宽: ' . $this->config->item('minimum_width'); ?>
                    <?php if ($this->config->item('minimum_height') && $this->config->item('minimum_width')) echo 'x'; ?>
                    <?php if ($this->config->item('minimum_height')) echo $this->config->item('minimum_height') . ' 高'; ?>
                </p>
            </div>
        </div>

        <div class="form-group">
            <label for="wallpaper_tags">标签</label>
            <input data-role="tagsinput" placeholder="多个标签用英文,号隔开" name="wallpaper_tags" class="form-control input-sm"
                   value="<?php echo set_value('wallpaper_tags', ($wallpaper ? $wallpaper->tags : '')); ?>"
                   type="text">
        </div>

        <div class="row">
            <div class="col-sm-4">
                <div class="form-group">
                    <label for="wallpaper_author">来源</label>
                    <input type="text" class="form-control" id="wallpaper_author" name="wallpaper_author"
                           value="<?php echo set_value('wallpaper_author', ($wallpaper ? $wallpaper->wallpaper_author : '')); ?>">
                </div>
            </div>
            <div class="col-sm-8">
                <div class="form-group">
                    <label for="wallpaper_author_site">来源网址</label>
                    <input type="url" class="form-control" id="wallpaper_author_site" name="wallpaper_author_site"
                           value="<?php echo set_value('wallpaper_author_site', ($wallpaper ? $wallpaper->wallpaper_author_site : '')); ?>">
                </div>
            </div>
        </div>


        <div class="row">
            <div class="col-sm-8">
                <div class="form-group">
                    <label for="wallpaper_description">壁纸介绍</label>
                    <textarea name="wallpaper_description" class="redactor" id="wallpaper_description" cols="30"
                              rows="10"><?php echo set_value('wallpaper_description', ($wallpaper ? $wallpaper->wallpaper_description : '')); ?></textarea>
                </div>
            </div>
            <div class="col-sm-4">
                <div class="form-group">
                    <label for="wallpaper_metatitle">网页标题</label>
                    <input type="text" class="form-control" id="wallpaper_metatitle" name="wallpaper_metatitle"
                           placeholder="Meta Title"
                           value="<?php echo set_value('wallpaper_metatitle', ($wallpaper ? $wallpaper->wallpaper_metatitle : '')); ?>">
                </div>
                <div class="form-group">
                    <label for="wallpaper_metadescription">网页介绍</label>
                    <textarea class="form-control" id="wallpaper_metadescription"
                              name="wallpaper_metadescription"><?php echo set_value('wallpaper_metadescription', ($wallpaper ? $wallpaper->wallpaper_metadescription : '')); ?></textarea>
                </div>
                <div class="form-group">
                    <label for="wallpaper_metakeywords">网页关键词</label>
                    <input type="text" class="form-control" id="wallpaper_metakeywords" name="wallpaper_metakeywords"
                           placeholder="Meta keywords"
                           value="<?php echo set_value('wallpaper_metakeywords', ($wallpaper ? $wallpaper->wallpaper_metakeywords : '')); ?>">
                </div>
            </div>
        </div>

    </div>

    <div class="box-footer">
        <div class="">
            <button type="submit" name="s_e" class="btn btn-sm btn-success"><i class="fa fa-save"></i> 保存
            </button>
            <button type="submit" name="s_c" class="btn btn-sm btn-info"><i class="fa fa-crop"></i> 保存后关闭
            </button>
            <button type="submit" name="s_n" class="btn btn-sm btn-primary"><i class="fa fa-anchor"></i> 新增保存
            </button>
        </div>
    </div>
    <?php echo form_close(); ?>
</div>

